package com.action;

import java.io.UnsupportedEncodingException;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.bean.Student;
import com.bean.Teacher;
import com.dao.AdminDao;
public class FindusersAction extends ActionSupport{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private List<Student> studentlist; 
	private List<Teacher> teacherlist;
	private Student student;
	private int type;
	private int stuID;
	private int teaID;
	private String stuName;
	private String stuClass;
	private String stuMajor;
	public String getList(){
		System.out.println("111");
		AdminDao dao = new AdminDao();
		if(type==1){
		studentlist = dao.findStu();
		return SUCCESS;
		}else if(type==2){
		teacherlist = dao.findTea();
		return INPUT;
		
		}
		return null;
	}
	//模糊查找特定的学生信息
	public String findSpeStu(){
		AdminDao dao = new AdminDao();
		studentlist = dao.findSpecialStu(stuID);
		return SUCCESS;
		
	}
	//模糊查找特定的教师信息
	public String findSpeTea(){
		AdminDao dao = new AdminDao();
		teacherlist = dao.findSpecialTea(teaID);
		return SUCCESS;
		
	}
	//精确查询特定学生信息

	public String findRefinedStu(){
		AdminDao dao = new AdminDao();
		studentlist = dao.findRefinedStu(student);
		return SUCCESS;
			
	}
	
	public String teafindRefinedStu(){
		AdminDao dao = new AdminDao();
		Student stu = new Student();
		stu.setStuUserID(stuID);
		try {
			String stuname = new String(stuName.getBytes("iso-8859-1"),"UTF-8");
			String stumajor = new String(stuMajor.getBytes("iso-8859-1"),"UTF-8");
			String stuclass = new String(stuClass.getBytes("iso-8859-1"),"UTF-8");
			stu.setStuName(stuname);
			stu.setMajor(stumajor);
			stu.setBelongclass(stuclass);
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		studentlist = dao.findRefinedStu(stu);
		return SUCCESS;
			
	}
	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public List<Student> getStudentlist() {
		return studentlist;
	}
	public void setStudentlist(List<Student> studentlist) {
		this.studentlist = studentlist;
	}
	public List<Teacher> getTeacherlist() {
		return teacherlist;
	}
	public void setTeacherlist(List<Teacher> teacherlist) {
		this.teacherlist = teacherlist;
	}

	public int getStuID() {
		return stuID;
	}

	public void setStuID(int stuID) {
		this.stuID = stuID;
	}

	public int getTeaID() {
		return teaID;
	}

	public void setTeaID(int teaID) {
		this.teaID = teaID;
	}

	public Student getStudent() {
		return student;
	}

	public void setStudent(Student student) {
		this.student = student;
	}
	public String getStuName() {
		return stuName;
	}
	public void setStuName(String stuName) {
		this.stuName = stuName;
	}
	public String getStuClass() {
		return stuClass;
	}
	public void setStuClass(String stuClass) {
		this.stuClass = stuClass;
	}

	public String getStuMajor() {
		return stuMajor;
	}
	public void setStuMajor(String stuMajor) {
		this.stuMajor = stuMajor;
	}

	
	
}
